 # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

import shutil

class Recipe(recipe.Recipe):
    """
    Ships the introspection.m4 macro file from the gobject-introspection tarball
    """
    name = 'gobject-introspection-m4'
    _name = 'gobject-introspection'
    version = '1.50.0'
    stype = SourceType.TARBALL
    maj_ver = '.'.join(version.split('.')[0:2])
    url = 'http://ftp.gnome.org/pub/GNOME/sources/{0}/{2}/{0}-{1}.tar.xz'
    url = url.format(_name, version, maj_ver)
    srcdir = "{0}-{1}".format(_name, version)
    licenses = [License.GPLv2Plus]
    btype = BuildType.CUSTOM
    files_devel = ['share/aclocal/introspection.m4']

    def prepare(self):
        self.build_dir = os.path.join(os.path.dirname(self.build_dir),
                                      '{0}-{1}'.format(self._name,
                                          self.version))

    def install(self):
        shutil.copy(os.path.join(self.build_dir, 'm4', 'introspection.m4'),
                    os.path.join(self.config.prefix, 'share', 'aclocal'))
